package com.sailorj.medical.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.List;

import com.sailorj.medical.domain.paybase.PayBase;
import com.sailorj.medical.exception.DbException;
import com.sailorj.medical.util.MyTime;

public class PayBaseDao extends GenericDao<PayBase> {

	@Override
	protected PayBase handle(ResultSet rs) throws SQLException {
		String id = rs.getString("id");
		String year = rs.getString("year");
		String money = rs.getString("money");
		Timestamp startTime = rs.getTimestamp("startTime");
		Timestamp endTime = rs.getTimestamp("endTime");

		PayBase entity = new PayBase(id, year, money, startTime, endTime);
		return entity;
	}

	/**
	 * 
	 * @Title: findByYear @Description:按年份查询标准基金
	 */
	public List<PayBase> findByYear() throws DbException {
		String year = MyTime.getStringNowYear();
		try {
			String sql = "select * from t_paybase where 1=1 and year=" + year + "";

			Object[] params = {};

			return super.queryOjects(sql, params);
		} catch (SQLException e) {
			throw new DbException("按级别查找行政区域失败!", e);
		}
	}
}
